define([
    'jquery',
    'handlebars'
], function($, Handlebars) {
    'use strict';
    Handlebars.registerHelper('myIndex', function(index) {
        return index + 1;
    });
    Handlebars.registerHelper('safe', function(msg) {
        return '<div>safe '+ msg || "" +'</div>';
    });
    Handlebars.registerHelper('notFirst', function(index){
        return index > 0;
    })
    Handlebars.registerHelper('showBgClass', function(count) {
        if(count < 10){
            return "bg1";
        }else if(count < 20){
            return "bg2";
        }else if(count < 30){
            return "bg3";
        }else{
            return "bg4";
        }
    });
    return {
        renderTemplate:function(templateId, wrapperId, data) {
            var tpl = $("#" + templateId).html();
            var template = Handlebars.compile(tpl);
            $("#" + wrapperId).html(template(data));
        },
        renderTpl:function(wrapperId, tpl, data){
            var template = Handlebars.compile(tpl);
            $("#" + wrapperId).html(template(data));
        }
    }
});